package com.tandashi.springbootstudy01.service.study;

import com.tandashi.springbootstudy01.entity.user.LoginUser;

import java.util.Objects;

public abstract class StudyContext {
    private static final ThreadLocal<LoginUser> STUDY_THREAD_LOCAL = new ThreadLocal<>();

    public static LoginUser get(){
        return STUDY_THREAD_LOCAL.get();
    }

    public static void set(LoginUser user){
        STUDY_THREAD_LOCAL.set(Objects.requireNonNull(user));
    }

    public static void remove(){
        STUDY_THREAD_LOCAL.remove();
    }
}
